package ece.com.controler;

import java.awt.Color;
import java.util.Observable;
import java.util.Observer;

import ece.com.gui.Gui_Landing;
import ece.com.intefaces.ILandingGear;
import ece.com.model.LandingGear;
import ece.com.model.TimeLanding;

public class LandingDoorControler implements Observer, ILandingGear {

	private LandingGear l=null;
	private Gui_Landing guiLanding;
	
	public LandingDoorControler(LandingGear l, Gui_Landing guiGear){
		this.l=l;
		this.guiLanding=guiGear;
	}
	
	@Override
	public void update(Observable obs, Object obj) {
		if(obs instanceof TimeLanding){
				TimeLanding tg = (TimeLanding) obs;
				if(obj instanceof String){
					
					String action = (String) obj;
					
					if(!l.isStopAll()){
						
//						System.out.println("FAILED : "+action);
						l.setStopAll(true);
						//mettre toute la roue en rouge
						if(action.equals(ACTION_DOOR_UP_TO_DOWN)
							||action.equals(ACTION_DOOR_DOWN_TO_UP)
							||action.equals(ACTION_DOOR_UNLOCK_UP)
							||action.equals(ACTION_DOOR_LOCK_UP))
							guiLanding.majColorDoor(Color.RED);
						else
							guiLanding.majColorGear(Color.RED);
					}
				}

}
		
	}
	
}
